package com.kg.sdk;
import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferencesCtrl {
    private final SharedPreferences mSpfs;

    public SharedPreferencesCtrl(Context context, String name) {
        mSpfs = context.getSharedPreferences(name, Context.MODE_MULTI_PROCESS);
    }

    public boolean contains(String key) {
        return mSpfs.contains(key);
    }

    public long getLong(String key, long defValue) {
        return mSpfs.getLong(key, defValue);
    }

    public boolean getBoolean(String key, boolean defValue) {
        return mSpfs.getBoolean(key, defValue);
    }

    public int getInt(String key, int defValue) {
        return mSpfs.getInt(key, defValue);
    }

    public float getFloat(String key, float defValue) {
        return mSpfs.getFloat(key, defValue);
    }

    public String getString(String key, String defValue) {
        return mSpfs.getString(key, defValue);
    }

    public void put(String key, long value) {
        SharedPreferences.Editor editor = mSpfs.edit();
        editor.putLong(key, value);
        editor.apply();
    }

    public void put(String key, boolean value) {
        SharedPreferences.Editor editor = mSpfs.edit();
        editor.putBoolean(key, value);
        editor.apply();
    }

    public void put(String key, int value) {
        SharedPreferences.Editor editor = mSpfs.edit();
        editor.putInt(key, value);
        editor.apply();
    }

    public void put(String key, float value) {
        SharedPreferences.Editor editor = mSpfs.edit();
        editor.putFloat(key, value);
        editor.apply();
    }

    public void put(String key, String value) {
        SharedPreferences.Editor editor = mSpfs.edit();
        editor.putString(key, value);
        editor.apply();
    }

    public void remove(String key) {
        SharedPreferences.Editor editor = mSpfs.edit();
        editor.remove(key);
        editor.apply();
    }

    public void clear() {
        SharedPreferences.Editor editor = mSpfs.edit();
        editor.clear();
        editor.apply();
    }
}
